//HX711.c
//全电流桥传感器A/D芯片
#include <regx52.h>


sbit HX711_SCK = P3^0;
sbit HX711_DOUT = P3^1;



void HX711_Init() {  
    HX711_SCK = 0;     // 初始时钟拉低  
    HX711_DOUT = 1;       // 等待数据就绪  
}


unsigned long ReadCount(void){
    unsigned long Count;
    unsigned char i;
    HX711_DOUT=1;
    HX711_SCK=0;
    Count=0;
    while(HX711_DOUT);
    for (i=0;i<24;i++){
        HX711_SCK=1;
        Count=Count<<1;
        HX711_SCK=0;
        if(HX711_DOUT) Count++;
    }
    HX711_SCK=1;
    Count=Count^0x800000;
    HX711_SCK=0;
    return(Count);
}


void HX711_Reset() {
    HX711_SCK=0;
    HX711_SCK=1;
}

